import datetime
def get_first_day_of_month(year, month):
    return datetime.date(year, month, 1).weekday()
def get_days_in_month(year, month):
    if month == 12:
        return (datetime.date(year + 1, 1, 1) - datetime.date(year, month, 1)).days
    else:
        return (datetime.date(year, month + 1, 1) - datetime.date(year, month, 1)).days
def print_calendar(year, month):
    monthE=month
    print("{}年-{:02d}的⽇历图：    July 2022".format(year, month))
    print("Mo Tu We Th Fr Sa Su")
    days_in_month = get_days_in_month(year, month)
    first_day_of_month = get_first_day_of_month(year, month)
    current_day = 1
    for i in range(0,6):
        row = ""
        for j in range(0,7):
            if i == 0 and j < first_day_of_month:
                row += " "
            elif current_day > days_in_month:
                break
            else:   
                row += "{:2d} ".format(current_day)
                current_day += 1
        print(row)

print_calendar(2023, 7)